package com.neuedu.io;

import java.io.*;

public class StreamDemo3 {
    public static void main(String[] args) {
        //0000 0000  1111 1111   0 - 255    0 - 65535
       File  file = new File("D:/《唐人的餐桌》.txt");
       File file2 = new File("D:/b.txt");
       if(!file2.exists()) {
           try {
               file2.createNewFile();
           } catch (IOException e) {
               throw new RuntimeException(e);
           }
       }
        InputStream  in;
        OutputStream  os;

        try {
            in = new FileInputStream(file);
            os = new FileOutputStream(file2);
            byte []  bt = new byte[1024];
            int ch = 0;
            int length=0;
            while( (ch = in.read())!=-1){
                    os.write(ch);
            }

//            while( (length= in.read(bt))!=-1) {
//
//                os.write(bt);
//
////                for(byte  b : bt){
////                    System.out.print((char)b);
////                }
//                os.write(bt);
//                System.out.println(length);
//            }

            in.close();
            os.close();
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
        catch (IOException e){

        }

    }
}
